package com.example.demo.service.impl;

import cn.hutool.core.util.StrUtil;
import com.example.demo.entity.SynRecord;
import com.example.demo.mysqlDao.MysDao;
import com.example.demo.response.JsonData;
import com.example.demo.service.SynRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @需求描述:
 * @创建人:whh
 * @创建时间: 2020/6/12
 * @修改需求:
 * @修改人:
 * @修改时间:
 * @需求思路:
 */

@Service
public class SynRecordServiceImpl implements SynRecordService {

    @Autowired
    private MysDao mysDao;

    @Override
    public Map findAllSynRecord(String synType,String page,String limit) {

        int size = this.mysDao.findAllSynRecord(synType).size();
        //分页
        if (StrUtil.isNotBlank(page) && StrUtil.isNotBlank(limit)) {
            PageHelper.startPage(Integer.parseInt(page), Integer.parseInt(limit), false);
        }
        List<SynRecord> records = this.mysDao.findAllSynRecord(synType);
        return JsonData.returnLayuiMap(records,size);
    }

    @Override
    public Map getSynStatistics(String synType, String page, String limit) {

        int size = this.mysDao.getSynStatistics(synType).size();
        //分页
        if (StrUtil.isNotBlank(page) && StrUtil.isNotBlank(limit)) {
            PageHelper.startPage(Integer.parseInt(page), Integer.parseInt(limit), false);
        }
        List<SynRecord> records = this.mysDao.getSynStatistics(synType);
        return JsonData.returnLayuiMap(records,size);
    }
}
